﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Simple.Master"
    CodeBehind="popupFornecedor.aspx.cs" Inherits="ELoje_web.popupFornecedor" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <base target="_self" />

    <script type="text/javascript">
        function fctSelecao(objRadio) {
            $("#<%=this.hdnReturnValue.ClientID %>").val(objRadio.value);
        }

        function fctConfirmar() {
            if ($.trim($("#<%= this.hdnReturnValue.ClientID %>").val()) == "") {
                alert('Selecione um item da lista')
                return false;
            }

            var objRetorno = new Object();
            objRetorno.COD_FORNECEDOR = $("#<%=this.hdnReturnValue.ClientID %>").val().split('')[0];
            objRetorno.DESC_FORNECEDOR = $("#<%=this.hdnReturnValue.ClientID %>").val().split(',')[1];

            window.returnValue = objRetorno;
            self.close();
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:Label ID="lblThisPage" runat="server" Style="font-weight: bold"></asp:Label>
    <hr class="hr1" />
    <div class="divGridCenter" style="margin: 0 auto">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <asp:UpdatePanel ID="upGrid" runat="server">
            <ContentTemplate>
                <div id="divTam" style="height: 305px; margin: 0 auto;">
                    <asp:GridView ID="gvClientes" runat="server" AutoGenerateColumns="false"
                        PageIndex="0" PageSize="10"
                        AllowPaging="true" AllowSorting="true"
                        OnSorting="gvClientes_Sorting" OnRowCreated="gvClientes_RowCreated" OnPageIndexChanging="gvClientes_PageIndexChanging" Width="95%">
                        <HeaderStyle BackColor="#336699" Font-Bold="true" ForeColor="#FFFFFF" CssClass="gridViewHead" />
                        <RowStyle BackColor="#FFFFFF" CssClass="gridViewField" />
                        <PagerStyle CssClass="gridViewField" />
                        <AlternatingRowStyle BackColor="#d1dce8" />
                        <Columns>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <input type="radio" name="rdrSelecao" onclick="fctSelecao(this);" value='<%#String.Format("{0},{1}", Eval("COD_FORNECEDOR"), Eval("NOMEFANTASIA")) %>' />
                                </ItemTemplate>
                                <ItemStyle Width="30px" />
                            </asp:TemplateField>
                            <asp:TemplateField>
                                <HeaderTemplate>
                                    <div style="width: 100%; text-align: center">
                                        <div class="floatLeft" style="width: 87px">
                                            Fornecedor
                                        </div>
                                        <div id="divColQuebralinha" class="floatLeft" style="width: 13px; height: 100%; margin-top: 13px"
                                            runat="server">
                                        </div>
                                    </div>
                                </HeaderTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:Label runat="server" ID="lblCodFornecedor" Text='<%# Eval("COD_FORNECEDOR") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle Width="100px" />
                            </asp:TemplateField>
                            <asp:TemplateField>
                                <HeaderTemplate>
                                    Nome Fornecedor<span id="spanSeta" runat="server"></span>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:Label runat="server" ID="lblNomeForn" Text='<%# Eval("NOMEFANTASIA") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <EmptyDataRowStyle CssClass="msgEmptyList" />
                        <EmptyDataTemplate>
                            Dados não encontrados
                        </EmptyDataTemplate>
                    </asp:GridView>
                    <asp:HiddenField ID="hdnBranch" runat="server" />
                    <asp:HiddenField ID="hdnStart" runat="server" />
                    <asp:HiddenField ID="hdnShortExpression" runat="server" />
                    <asp:HiddenField ID="hdnSortDirection" runat="server" />
                    <asp:HiddenField ID="hdnReturnValue" runat="server" />
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnStart" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
    <div style="width: 390px; text-align: center; margin-top: 13px;">
        <div class="buttonCollor floatLeft">
            <asp:Button runat="server" ID="btnStart" CssClass="buttonStyles" OnClick="btnStart_Click" />
        </div>
        <div class ="floatLeft" style="margin-left: 4px; padding-top: 5px;">
            <label>
                <asp:TextBox ID="txtDESC" MaxLength="20" Width="250px" runat="server" />
            </label>
        </div>
    </div>
    <div style="width: 200px; margin-top: 2px;">
        <div class="buttonCollor" style="float: left">
            <asp:Button runat="server" ID="btnCancel" OnClientClick="javascript:self.close();return false;"
                CssClass="buttonStyles" />
        </div>
        <div class="buttonCollor">
            <asp:Button runat="server" ID="btnSelect" OnClientClick="fctConfirmar(); return false;"
                CssClass="buttonStyles" />
        </div>
    </div>
</asp:Content>
